<?

if(!class_exists('BasicDataStructure')){
    Module::Init('frost.structure');
}

IncludeClass('FLDValues', __DIR__."/classes/");

class Fields extends BasicDataStructure{
    protected static $table = "fld__fields";
    protected static $pid_name = "container_id";
    
    static function GetFields($id, $bid,$type){
        $filter = array(
            array('field' => 'block_id', 'value' => $bid),
            array('field' => 'type', 'value' => $type),
        );
        $result = static::GetTree($filter);
        foreach($result as $i=>$field){
              $filter_v = array(
                    array('field' => 'field_id', 'value' => $field['id']),
                    array('field' => 'relation', 'value' => $type),
                    array('field' => 'parent_id', 'value' => $id),
                );
             $valObj = FLDValues::GetList($filter_v);
             while($value = $valObj->Fetch()){
                $result[$i]['values'][] = $value['value'];
             }
        }
        return $result;
    }
}